import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';

class DeviceDirection {

  ///横屏
  static Future<void> landscape() async {
    await SystemChrome.setPreferredOrientations(
        [DeviceOrientation.landscapeLeft,DeviceOrientation.landscapeRight]);
  }

  ///指定方向横屏
  static Future<void> landscapeByOrien(List<DeviceOrientation> list) async {
    await SystemChrome.setPreferredOrientations(list);
  }

  ///竖屏
  static Future<void> portrait() async {
    await SystemChrome.setPreferredOrientations(
        [DeviceOrientation.portraitUp]);
  }

  ///获取屏幕的方向
  static Future<Orientation> getOrientation(BuildContext context) async {
    Orientation currentOrientation = MediaQuery.of(context).orientation;
    return currentOrientation;

  }
}